package roleView 
{
	import core.IColorContainer;
	import core.Vector2D;
	import flash.display.MovieClip;
	import flash.events.DataEvent;
	import view.ISkin;
	
	
	/**
	 * ...
	 * @author Kylin206
	 */
	public class RoleSkin extends MovieClip implements IColorContainer,ISkin
	{
		static public const UPDATA_ARMOUR:String = "updataArmour";
		static public const UPDATA_HAT:String = "updataHat";
		static public const UPDATA_WEAPON:String = "updataWeapon";
		
		static public const colors = [0xFF3333,0x33CC33,0x3333FF];
		
		private var _color:uint = 0;
		private var colorsI:uint = 0;
		
		private var _isWeaponUp:Boolean = false;//武器升级
		private var _isHatUp:Boolean = false;//头盔升级
		private var _isArmourUp:Boolean = false;//盾牌升级
		
		public function RoleSkin() 
		{
			//stop();
			color = colors[colorsI];
			trace("*RoleSkin Created", this);
			//this.cacheAsBitmap = true;
			//this.addEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		
		/* INTERFACE view.ISkin */
		
		public function setPostion(pos:Vector2D):void 
		{
			this.x = pos.x;
			this.y = pos.y;
		}
		
		public function moveto(pos:Vector2D):void 
		{
			setPostion(pos);
		}
		
		/*
		private function onAdded(e:Event):void 
		{
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKey);
			removeEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		
		private function onKey(e:KeyboardEvent):void 
		{
			if(e.keyCode == Keyboard.SPACE)
			{
				colorsI++;
				if (colorsI == colors.length)
				{
					colorsI = 0;
				}
				color = colors[colorsI];
			}
		}
		*/
		
		
		public function set color(value:uint):void 
		{
			_color = value;
			this.dispatchEvent(new DataEvent(ColorItemConst.COLOR_CHANGED, false, false, _color.toString()));
		}
		
		public function get color():uint 
		{
			return _color;
		}
		
		public function get isWeaponUp():Boolean 
		{
			return _isWeaponUp;
		}
		
		public function set isWeaponUp(value:Boolean):void 
		{
			var s:String;
			if (value) s = "1";
			else s = "0";
			_isWeaponUp = value;
			this.dispatchEvent(new DataEvent(UPDATA_WEAPON, false, false, s));
		}
		
		public function get isHatUp():Boolean 
		{
			return _isHatUp;
		}
		
		public function set isHatUp(value:Boolean):void 
		{
			var s:String;
			if (value) s = "1";
			else s = "0";
			_isHatUp = value;
			this.dispatchEvent(new DataEvent(UPDATA_HAT, false, false, s));
		}
		
		public function get isArmourUp():Boolean 
		{
			return _isArmourUp;
		}
		
		public function set isArmourUp(value:Boolean):void 
		{
			var s:String;
			if (value) s = "1";
			else s = "0";
			_isArmourUp = value;
			this.dispatchEvent(new DataEvent(UPDATA_ARMOUR, false, false, s));
		}
		
		
	}

}